home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3606 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  31 lines

  1. Newsgroups: comp.lang.c
  2. Path: nntp.coast.net!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: Re: need help on direct keyboard input
  5. Message-ID: <DLz0CF.H1C@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <4ejj1a$bi1@lisa.cs.mcgill.ca>
  8. Date: Tue, 30 Jan 1996 01:33:51 GMT
  9.  
  10. In article <4ejj1a$bi1@lisa.cs.mcgill.ca> hus@marge.cs.mcgill.ca (Song HU) writes:
  11. >Hi,expert:
  12. >  I used programing in Basic language, there is a function name "
  13. >  inkey$", it will get one character from keyboard and do something.
  14. >  now, I would like to make a similar function in C, I try getchar()
  15. >  read() and other input function. they won't process the input unless
  16. >  you press Enter on you keyboard, is there somebody know how can
  17. >  program it in C?
  18. >
  19. >  Thank you for any suggestion
  20.  
  21.     The C language does not support anything specific for that type
  22.     of input.  Each o/s has a specific solution for this. For DOS
  23.     platforms, you can use the non-ANSI function getch() which
  24.     should be available in all DOS compilers.  You might also want
  25.     to look at kbhit(). However, your code will not be portable to
  26.     other platforms.
  27. -- 
  28. John A. Grant                        jagrant@emr1.emr.ca
  29. Airborne Geophysics
  30. Geological Survey of Canada, Ottawa
  31.